<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no">
	   	<title>{$room['title']}</title>
	    <link href="/static/weike/css/style.css" rel="stylesheet">
	    <script src="/static/js/jquery.js"></script>
	    <script src="/static/weike/js/style.js"></script>
	</head>
	<body class="class_pay" id="{$identity}">
	    <input type="hidden" id="user_id" value='{$user_id}' name="用户ID" />
	    <input type="hidden" id="room_id" value='{$room["room_id"]}' name="房间ID" />
	    <input type="hidden" id="teacher_id" value='{$teacher["user_id"]}' name="老师ID" />
	    <input type="hidden" class="_php_" value='{$config}' name="用户对房间的状态" />
		<div class="banner">
		    <aside class="control">
		        <!--邀请卡邀请链接-->
<div onclick="javascript:window.location.href='http://mg.bonayiyou.com/index/home/person_invite.html?room_id={$room_id}&user_id={$user_id}'" >
				</div>
				<!--<div>编辑</div>-->
			</aside>
			<img src="{$room['cover']}" />
		</div>
		<header>
			<div>
				<h5>{$room['title']}</h5>
				<p>￥{$room['room_price']}</p>
				<p><span>{$room['zhuangtai']}</span><span>{$room['popul_num']|add_wan}人气</span></p>
			</div>
		</header>
		<div class="per_reset student_none">
			<div >
				<article></article>
			</div>
		</div>
		<div class="set">
			<article>
				<article>
				<!-- 设置里面写链接的地方 -->
					<section id="edit"><div ></div></section><!-- 课程编辑 -->
					<section id="addlunbo"><div ></div></section><!-- 添加课件 -->
				</article>
				<aside class="set_close">取消</aside>
			</article>
		</div>
		<article>
			<section>
				<header>讲师介绍</header>
				<div>
					<div>
						<img src="{$teacher['headpic']}" />
					</div>
					<div>
						<div>关注</div>
						<input type="checkbox" class="_php"/>
						<div>已关注</div>
					</div>
				</div>
				<div>
					<p>{$teacher['nickname']}</p>
					<div>
						{$teacher['introduce']}
					</div>
				</div>
			</section>
			<section>
				<header>课程介绍</header>
				<div>
					{$room['introduce']}
				</div>
			</section>
		</article>
		<div class="sure">
			<div>
				<p>确认购买</p>
				<p>是否确认花费<span>￥</span><span>{$room['room_price']}</span>购买该课程</p>
				<div>
					<button>暂不购买</button>
					<button class="sure_pay" onclick="callpay()">确认购买</button>
				</div>
			</div>
		</div>
		<footer class="choose_class ">
			<div class="collect">
				<input type="checkbox" class="_php" />
				<div></div>
			</div>
			<button class="pay_class">购买课程</button>
			<button class="enter_class" id="enter_room">进入课程</button>
		</footer>
	</body>
	<script type="text/javascript">
	//调用微信JS api 支付
	function jsApiCall()
	{
		WeixinJSBridge.invoke(
			'getBrandWCPayRequest',
			<?php echo $jsApiParameters;?>,
			function(res){
				WeixinJSBridge.log(res.err_msg);
				//alert(res.err_msg);
				//alert(res.err_msg.length);
				//如果购买成功
				if(res.err_msg=="get_brand_wcpay_request:ok")
				{
				//alert("进入了页面");	
				var data={};
				data['room_price']="{$room['room_price']}";
				data['room_id']   ="{$room['room_id']}";
				data['user_id']   ="{$user_id}";
				//alert(JSON.stringify(data));
				var url="http://mg.bonayiyou.com/index/home/add_pay_recoder";
				$.post(url,data,function(e){},"JSON");	
				//支付成功后跳转到直播房间
				window.location.href="http://mg.bonayiyou.com/index/home/class_pay?room_id={$room['room_id']}";
			    }
			    // else
			    // {
			    // 	alert('没有进入页面');
			    // }
			}
		);
	}
	function callpay()
	{
		if (typeof WeixinJSBridge == "undefined"){
		    if( document.addEventListener ){
		        document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
		    }else if (document.attachEvent){
		        document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
		        document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
		    }
		}else{
		    jsApiCall();
		}
	}
	$("#enter_room").on('click',function()
	{
     window.location.href="http://mg.bonayiyou.com/index/home/weike_chizbo?room_id={$room['room_id']}";
	});
	$("#edit").on('click',function()
	{
     window.location.href="http://mg.bonayiyou.com/index/home/person_updateobj?room_id="+"{$room['room_id']}";
	});
	$("#addlunbo").on('click',function()
	{
     window.location.href="http://mg.bonayiyou.com/index/home/weike_img_lunbo?room_id="+"{$room['room_id']}";
	});
	window.addEventListener("load",function(){
		var img = document.getElementsByTagName("img")[0];
		if( img.height/0.4 < img.width/0.9){
			img.setAttribute("class","height");
		}
	})
	</script>
</html>
